#pragma once 

namespace Melting
{
	struct KeyValue
	{
		UINT16          muiKeySize;
		UINT16          muiValueSize;
		const char*     mxstrKey;
		const char*     mxstrValue;
	};
 
	class ScriptParser
	{
	public:

		ScriptParser( UINT32 _uiMaxEntries );
		~ScriptParser( void );

		bool							Parse(	const char* _strScript, UINT32 _uiScriptSize, char _cEntriesSeparator
											, char _cKeyValueSeparator, char _cCommentTag, bool _bIsValueOptionnal );


		inline UINT32					GetNbEntries( void ) const;
		inline const KeyValue&			GetEntry( UINT32 _uiIndex ) const;

	private:

		DynamicArray< KeyValue, UINT16 > maEntries;
	};

	
	UINT32	ScriptParser::GetNbEntries( void ) const
	{
		return maEntries.GetSize();
	}

	const KeyValue&	ScriptParser::GetEntry( UINT32 _uiIndex ) const
	{
		//-----------------------------
		// precondition
		MB_ASSERT_MAX( _uiIndex, GetNbEntries() - 1, "Index out of bounds\n" );
		//-----------------------------
		return maEntries[ _uiIndex ];
	}
}